ids = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM_"

# 判断id
def is_id(id):
    if 0 < len(id) <= 8:
        for i in id:
            if i not in ids:
                return False
                break
        return True
    return False

#判断Email，email.count("@")计字符出现次数，.find("@")字符第一次出现的索引，.replace("@", "")去除指定字符
def is_email(email):
    a = email.count("@")
    b = email.count(".")
    c = email.find("@")
    d = email.find(".")
    e = email.replace("@", "")
    e = e.replace(".", "")
    if a == b ==1:
        if (0 < c) & (c < d-1) & (d < len(email)-1):
            for i in id:
                if i not in ids:
                    return False
                    break
            return True
    return False

# 判断身份证,idcn.replace(id[-1], "")把最后一个字符去掉，idcn.isdigit()判断是否全数字
def is_idcn(idcn):
    if len(idcn) == 18:
        if idcn[-1] in ["x", "X"]:
            idx = id.replace(idcn[-1], "")
            idx = idx.isdigit()
            if idx:
                return True
            return False
        elif id.isdigit():
            return True
    return False

#判断名字
def is_name(name):
    if 0 < len(name) <= 4:
        if is_Chinese(name):
            return True
    return False

# 判断是否中文 \u4e00——\u9fff，中文范围
def is_Chinese(word):
    for ch in word:
        if not '\u4e00' <= ch <= '\u9fff':
            return False
    return True

# def is_true(a):
#     c = "4k123"
#     print(c)
#     t = "is_"+a+"("+c+")"
#     print(eval(t))
#     print(t)
#
#     while True:
#         if t:
#             break
#         else:
#             id = input("请重新输入id：")
#             t = a(id)
# is_true("id")
while True:
    id = input("请输入id：")
    while True:
        if is_id(id):
            break
        else:
            id = input("请重新输入id：")

    email = input("请输入email：")
    while True:
        if is_email(email):
            break
        else:
            email = input("请重新输入email：")

    idcn = input("请输入身份证：")
    while True:
        if is_idcn(idcn):
            s = int(idcn[-2])
            s = s % 2
            if s == 0:
                sex = "女"
            else:
                sex = "男"
            break
        else:
            idcn = input("请重新输入身份证：")

    name = input("请输入姓名：")
    while True:
        if is_name(name):
            break
        else:
            name = input("请重新输入name：")
    print("id：{}\nemail：{}\n身份证：{}\nname：{}\nsex：{}".format(id, email, idcn, name, sex))
    break
